<template>
  <div id="uncollectedManages">
    <el-card class="box-card" style="margin:15px">
      <el-form
        ref="basicForm"
        :rules="basicDataRules"
        :inline="true"
        :model="basicData.model"
        class="demo-form-inline"
        size="mini"
        label-width="100px"
      >
        <el-row>
          <el-col :span="6">
            <el-form-item label="所属区县:" prop="areaId.key" width="300px">
              <el-select
                size="mini"
                v-model="basicData.model.areaId.key"
                placeholder="选择"
                @change="clickOrgTree"
              >
                <el-option
                  v-for="(item, index) in orgTree"
                  :key="index"
                  :label="item.label"
                  :value="item.id"
                  width="300px"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="所属医院:" prop="hospitalId.key">
              <el-select
                size="mini"
                v-model="basicData.model.hospitalId.key"
                placeholder="选择"
                @change="clickOrgTreeC"
              >
                <el-option
                  v-for="(item, index) in orgTreeC"
                  :key="index"
                  :label="item.label"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="所属部门:" prop="departId.key">
              <el-select size="mini" v-model="basicData.model.departId.key" placeholder="选择">
                <el-option
                  v-for="(item, index) in orgTreeCs"
                  :key="index"
                  :label="item.label"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="母亲姓名:" prop="momName">
              <el-input
                @keyup.enter.native="getList(basicData)"
                size="mini"
                v-model="basicData.model.momName"
                placeholder="输入"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="条形码号:" prop="barCode">
              <el-input
                @keyup.enter.native="getList(basicData)"
                size="mini"
                v-model="basicData.model.barCode"
                placeholder="输入"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="采样状态:" prop="bloodStatus.key">
              <el-select size="mini" v-model="basicData.model.bloodStatus.key" placeholder="采样状态">
                <el-option
                  v-for="item in dicts.BLOOD_STATUS"
                  :key="item"
                  :label="item"
                  :value="item"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="归档状态:" prop="fileStatus.key">
              <el-select size="mini" v-model="basicData.model.fileStatus.key" placeholder="归档状态">
                <el-option
                  v-for="(item, key, index) in dicts.FILE_STATUS"
                  :key="index"
                  :label="item"
                  :value="key"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="出生日期:" prop="birthTime">
              <el-date-picker
                size="mini"
                style="width:80%"
                :format="birthTimeFormat"
                @focus="basicData.model.birthTime?basicData.model.birthTime:basicData.model.birthTime = ''"
                v-model="basicData.model.birthTime"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择日期"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="手机号码:" prop="phone">
              <el-input
                @keyup.enter.native="getList(basicData)"
                size="mini"
                v-model="basicData.model.phone"
                placeholder="输入"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="支付方式:" prop="payWay.key">
              <el-select size="mini" v-model="basicData.model.payWay.key" placeholder="支付方式">
                <el-option
                  v-for="(item, key, index) in dicts.PAY_WAY"
                  :key="index"
                  :label="item"
                  :value="key"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="费用类型:" prop="costType.key">
              <el-radio-group v-model="basicData.model.costType.key">
                <el-radio
                  v-for="(item, key, index) in dicts.COST_TYPE"
                  :key="index"
                  :label="key"
                >{{ item }}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-col id="shiyan" :span="18" class="more-col">
              <el-form-item label="实验项目:" prop="projectIdList" class="pj">
                <el-checkbox-group v-model="basicData.model.experimentProject">
                  <el-checkbox
                    v-for="(item, key, index) in dicts.EXPERIMENT_CODE"
                    :label="key"
                    name="type"
                  >{{ item }}</el-checkbox>
                </el-checkbox-group>
              </el-form-item>
            </el-col>
          </el-col>
        </el-row>
      </el-form>
      <div class="buttom">
        <el-button
          type="primary"
          size="mini"
          style="width:100px"
          icon="el-icon-search"
          @click="onSubmit('query')"
        >查询</el-button>
        <el-button size="mini" @click="onSubmit('reset')">重置</el-button>
      </div>
    </el-card>
    <el-card class="box-card" style="margin:5px 15px;">
      <div style="margin-bottom:10px">
        <el-button
          size="mini"
          type="primary"
          icon="el-icon-printer"
          :disabled="selectTables.length == 0"
          @click="clickEdit"
        >修改/打印</el-button>
        <el-button
          size="mini"
          type="primary"
          icon="el-icon-delete"
          :disabled="selectTables.length == 0"
          @click="clickDel"
        >删除</el-button>
        <el-button size="mini" @click="clickExport">导出</el-button>
        <el-button size="mini" @click="clickPgh" :disabled="selectTables.length == 0">归档</el-button>
        <el-button size="mini" :disabled="selectTables.length == 0" @click="clickRefund">退款审核</el-button>
      </div>
      <el-table
        v-loading="loading"
        :data="tableData"
        style="width: 100%;padding:5px;"
        :header-cell-style="{
          background: '#333333',
          color: '#ffffff',
          textAlign: 'center'
        }"
        @selection-change="clickTable"
        :row-style="announStyle"
      >
        <el-table-column align="center" type="selection" width="55" />
        <el-table-column align="center" prop="momName" label="母亲姓名" />
        <el-table-column
          align="center"
          prop="departId.data.label"
          label="所属部门"
          show-overflow-tooltip
        />
        <el-table-column align="center" prop="babySex.data" label="性别" />
        <el-table-column align="center" prop="barCode" label="条形码号" width="150" />
        <el-table-column align="center" prop="bloodStatus.data" label="采样状态" />
        <el-table-column align="center" prop="sampleQuality.data" label="样本质量" />
        <el-table-column align="center" prop="sourceWay.data" label="来源方式" />
        <el-table-column align="center" prop="payWay.data" label="支付方式" />
        <el-table-column align="center" prop="price" label="筛查价格" />
        <el-table-column align="center" prop="address" show-overflow-tooltip label="住址" />
        <el-table-column align="center" prop="fileStatus.data" label="归档" />
        <el-table-column align="center" prop="experimentKeywords.data" label="实验项目" />
        <el-table-column label="操作" align="center">
          <template slot-scope="scope">
            <el-button type="text" size="mini" @click="clickButtom(scope.row)">采样</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        :current-page="basicData.current"
        :page-size="basicData.size"
        :total="total"
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </el-card>

    <!-- 打印 -->
    <el-dialog :visible.sync="dialogPrint" width="40%" center custom-class="print-dialog">
      <span
        slot="title"
        class="dialog-title"
        style="font-size: 18px;font-weight: 400;color: #FFFFFF;"
      >{{ loadingTitle }}</span>
      <el-form
        id="addAndPrints"
        :inline="true"
        class="print-form"
        label-width="120px"
        label-position="left"
      >
        <div v-if="rowData.areaId.data" class="print-item">
          <span class="title">所属区县:</span>
          <span class="value">{{ rowData.areaId.data.label }}</span>
        </div>
        <div v-if="rowData.hospitalId.data" class="print-item">
          <span class="title">所属医院:</span>
          <span class="value">{{ rowData.hospitalId.data.label }}</span>
        </div>
        <div v-if="rowData.departId.data" class="print-item">
          <span class="title">所属部门:</span>
          <span class="value">{{ rowData.departId.data.label }}</span>
        </div>
        <div v-if="rowData.bloodNum" class="print-item">
          <span class="title">采血编号:</span>
          <span class="value">{{ rowData.bloodNum }}</span>
        </div>
        <div v-if="rowData.barCode" class="print-item">
          <span class="title">条形码号:</span>
          <span class="value">{{ rowData.barCode }}</span>
        </div>
        <div v-if="rowData.momName" class="print-item">
          <span class="title">母亲姓名:</span>
          <span class="value">{{ rowData.momName }}</span>
        </div>
        <div v-if="rowData.babySex" class="print-item">
          <span class="title">性别:</span>
          <span class="value">{{ rowData.babySex.data }}</span>
        </div>
        <div v-if="rowData.birthTime" class="print-item">
          <span class="title">出生日期:</span>
          <span class="value">{{ rowData.birthTime }}</span>
        </div>
        <div v-if="rowData.bloodTime" class="print-item">
          <span class="title">采血日期:</span>
          <span class="value">{{ rowData.bloodTime }}</span>
        </div>
        <div v-if="rowData.phone" class="print-item">
          <span class="title">手机号码:</span>
          <span class="value">{{ rowData.phone }}</span>
        </div>
        <div v-if="rowData.weight" class="print-item">
          <span class="title">婴儿体重:</span>
          <span class="value">{{ rowData.weight }}</span>
        </div>
        <div v-if="rowData.weeks" class="print-item">
          <span class="title">孕周:</span>
          <span class="value">{{ rowData.weeks }}</span>
        </div>
        <div v-if="rowData.days" class="print-item">
          <span class="title">孕天:</span>
          <span class="value">{{ rowData.days }}</span>
        </div>
        <div v-if="rowData.momCard" class="print-item">
          <span class="title">母亲身份证:</span>
          <span class="value">{{ rowData.momCard }}</span>
        </div>
        <div v-if="rowData.accountType" class="print-item">
          <span class="title">户口类型:</span>
          <span class="value">{{ rowData.accountType.data }}</span>
        </div>
        <div v-if="rowData.address" class="print-item">
          <span class="title">住址:</span>
          <span class="value">{{ rowData.address }}</span>
        </div>
        <div v-if="rowData.momCensus" class="print-item">
          <span class="title">母亲户籍:</span>
          <span class="value">{{ rowData.momCensus.data }}</span>
        </div>
        <div v-if="rowData.sampleQuality" class="print-item">
          <span class="title">样本质量:</span>
          <span class="value">{{ rowData.sampleQuality.data }}</span>
        </div>
        <div v-if="rowData.samplingPeople" class="print-item">
          <span class="title">采血人:</span>
          <span class="value">{{ rowData.samplingPeople }}</span>
        </div>
        <div v-if="rowData.remark" class="print-item">
          <span class="title">筛查备注</span>
          <span class="value">{{ rowData.remark }}</span>
        </div>
        <div v-if="rowData.experimentKeywords" class="print-item">
          <span class="title">实验项目:</span>
          <span class="value">{{ rowData.experimentKeywords.data }}</span>
        </div>
        <div v-if="rowData.costType.length > 0" class="print-item">
          <span class="title">费用类型:</span>
          <span class="value">{{ rowData.costType.data }}</span>
        </div>
        <div v-if="rowData.getexamineDoctor" class="print-item">
          <span class="title">送检医生:</span>
          <span class="value">{{ rowData.getexamineDoctor }}</span>
        </div>
        <div v-if="rowData.expNum" class="print-item">
          <span class="title">实验编号:</span>
          <span class="value">{{ rowData.expNum }}</span>
        </div>
        <div v-if="rowData.freeNum" class="print-item">
          <span class="title">免费券号:</span>
          <span class="value">{{ rowData.freeNum }}</span>
        </div>
        <div v-if="rowData.dadCard" class="print-item">
          <span class="title">父亲身份证:</span>
          <span class="value">{{ rowData.dadCard }}</span>
        </div>
      </el-form>
      <span v-if="printStatus" slot="footer" class="dialog-footer">
        <el-button
          v-print="'#addAndPrints'"
          size="mini"
          type="primary"
          style="padding: 6px 19px;"
        >打 印</el-button>
      </span>
    </el-dialog>

    <!-- 修改 -->
    <el-dialog :visible.sync="dialogEdit" width="85%" center custom-class="print-dialog">
      <span
        slot="title"
        class="dialog-title"
        style="font-size: 18px;font-weight: 400;color: #FFFFFF;"
      >{{ loadingTitle }}</span>

      <el-form
        ref="editForm"
        :rules="basicDataRules"
        :inline="true"
        :model="selectItem"
        class="demo-form-inline"
        label-width="100px"
        size="mini"
      >
        <el-row>
          <el-col :span="6">
            <el-form-item label="所属区县:" prop="areaId.key">
              <el-select
                size="mini"
                v-model="selectItem.areaId.key"
                placeholder="选择"
                @change="clickOrgTree"
              >
                <el-option
                  v-for="(item, index) in orgTree"
                  :key="index"
                  :label="item.label"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="所属医院:" prop="hospitalId.key">
              <el-select
                size="mini"
                v-model="selectItem.hospitalId.key"
                placeholder="选择"
                @change="clickOrgTreeC"
              >
                <el-option
                  v-for="(item, index) in orgTreeC"
                  :key="index"
                  :label="item.label"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="所属部门:" prop="departId.key">
              <el-select size="mini" v-model="selectItem.departId.key" placeholder="选择">
                <el-option
                  v-for="(item, index) in orgTreeCs"
                  :key="index"
                  :label="item.label"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="婴儿体重:" prop="weight">
              <el-input
                size="mini"
                v-model="selectItem.weight"
                type="text"
                oninput="value=value.replace(/[^\d.]/g,'')"
                placeholder="输入"
              >
                <template slot="append">克</template>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="孕周:" prop="weeks">
              <el-input
                size="mini"
                v-model="selectItem.weeks"
                type="text"
                oninput="value=value.replace(/[^\d.]/g,'')"
                placeholder="输入"
              >
                <template slot="append">周</template>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="孕天:" prop="days">
              <el-input
                size="mini"
                v-model="selectItem.days"
                placeholder="输入"
                type="text"
                oninput="value=value.replace(/[^\d.]/g,'')"
              >
                <template slot="append">天</template>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="户口类型:" prop="accountType" v-if="selectItem.accountType">
              <el-radio-group v-model="selectItem.accountType.key">
                <el-radio
                  v-for="(item, key, index) in dicts.ACCOUNT_TYPE"
                  :key="item"
                  :label="key"
                >{{ item }}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="出生日期:" prop="birthTime">
              <el-date-picker
                size="mini"
                :format="birthTimeFormat"
                @focus="selectItem.birthTime = ''"
                v-model="selectItem.birthTime"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择日期"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="性别:" prop="babySex">
              <el-radio-group v-model="selectItem.babySex.key">
                <el-radio
                  v-for="(item, key, index) in dicts.BABY_SEX"
                  :key="item"
                  :label="key"
                >{{ item }}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="母亲姓名:" prop="momName">
              <el-input size="mini" v-model="selectItem.momName" placeholder="输入" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="手机号码:" prop="phone">
              <el-input
                size="mini"
                v-model="selectItem.phone"
                placeholder="输入"
                type="text"
                maxlength="11"
                oninput="value=value.replace(/[^\d.]/g,'')"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="母亲身份证:" prop="momCard">
              <el-input size="mini" v-model="selectItem.momCard" placeholder="输入" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="母亲户籍:" prop="momCensus" v-if="selectItem.momCensus">
              <el-radio-group v-model="selectItem.momCensus.key">
                <el-radio
                  v-for="(item, key, index) in dicts.MOM_CENSUS"
                  :key="item"
                  :label="key"
                >{{ item }}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="住址:" prop="address">
              <el-input size="mini" v-model="selectItem.address" placeholder="输入" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="父亲身份证:" prop="dadCard">
              <el-input size="mini" v-model="selectItem.dadCard" placeholder="输入" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="条形码号:" prop="barCode">
              <el-input size="mini" v-model="selectItem.barCode" placeholder="输入" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="采血日期:" prop="bloodTime">
              <el-date-picker
                size="mini"
                :format="bloodTimeFormat"
                @focus="selectItem.bloodTime = ''"
                v-model="selectItem.bloodTime"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择日期"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="样本质量:" prop="sampleQuality" v-if="selectItem.sampleQuality">
              <el-select size="mini" v-model="selectItem.sampleQuality.key" placeholder="样本质量">
                <el-option
                  v-for="(item, key, index) in dicts.SAMPLE_QUALITY"
                  :key="item"
                  :label="item"
                  :value="key"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="采血人:" prop="samplingPeople">
              <el-input size="mini" v-model="selectItem.samplingPeople" placeholder="输入" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <el-form-item label="费用类型:" prop="costType" v-if="selectItem.costType">
              <el-radio-group v-model="selectItem.costType.key">
                <el-radio
                  v-for="(item, key, index) in dicts.COST_TYPE"
                  :key="item"
                  :label="key"
                >{{ item }}</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="采血编号:" prop="bloodNum">
              <el-input size="mini" v-model="selectItem.bloodNum" placeholder="输入" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="送检医生:" prop="getexamineDoctor">
              <el-input size="mini" v-model="selectItem.getexamineDoctor" placeholder="输入" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="实验编号:" prop="expNum">
              <el-input size="mini" v-model="selectItem.expNum" placeholder="输入" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col>
            <el-col :span="6">
              <el-form-item label="免费券号:" prop="freeNum">
                <el-input size="mini" v-model="selectItem.freeNum" placeholder="输入" />
              </el-form-item>
            </el-col>
          </el-col>
          <el-col id="shiyan" :span="18" class="more-col">
            <el-form-item label="实验项目:" prop="projectIdList" class="pj">
              <el-checkbox-group v-model="selectItem.experimentProject" @change="clickCheckBox">
                <el-checkbox
                  v-for="(item, key, index) in dicts.EXPERIMENT_CODE"
                  :label="key"
                  name="type"
                >{{ item }}</el-checkbox>
              </el-checkbox-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24" class="more-col">
            <el-form-item
              label="筛查备注:"
              label-width="66px"
              style="margin-left:0.9vw"
              class="remark"
              prop="remark"
            >
              <el-input size="mini" v-model="selectItem.remark" type="textarea" placeholder="输入" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>

      <span slot="footer" class="dialog-footer">
        <el-button
          size="mini"
          type="primary"
          style="padding: 6px 19px;"
          @click="onSubmit('seave')"
        >保存</el-button>
        <el-button size="mini" icon="el-icon-printer" @click="onSubmit('seaveAndPrint')">保存并打印</el-button>
      </span>
    </el-dialog>

    <!-- 归档 -->
    <el-dialog :visible.sync="gdShow" width="80%" center custom-class="print-dialog" id="guidang">
      <span
        slot="title"
        class="dialog-title"
        style="font-size: 18px;font-weight: 400;color: #FFFFFF;"
      >结论修改</span>
      <div class="edit-dialog" v-if="selectItem.momName">
        <div class="mores" style="margin-bottom:20px">
          <div class="more-title">基础信息</div>
        </div>
        <el-row style="line-height: 1.5;">
          <el-col :span="8">
            <span style="margin:30px">母亲姓名:</span>
            <span>{{ selectItem.momName }}</span>
          </el-col>
          <el-col :span="8">
            <span style="margin:30px">出生日期:</span>
            <span>{{ selectItem.birthtime }}</span>
          </el-col>
          <el-col :span="8">
            <span style="margin:30px">性 别:</span>
            <span>{{ selectItem.babySex.data }}</span>
          </el-col>
          <el-col :span="8">
            <span style="margin:30px">手机号码:</span>
            <span>{{ selectItem.phone }}</span>
          </el-col>
          <el-col :span="8">
            <span style="margin:30px">电话号码:</span>
            <span></span>
          </el-col>
          <el-col :span="8">
            <span style="margin:30px">住院号:</span>
            <span></span>
          </el-col>
          <el-col :span="8">
            <span style="margin:30px">床位号：</span>
            <span></span>
          </el-col>
          <el-col :span="8">
            <span style="margin:30px">分娩方式：</span>
            <span></span>
          </el-col>
          <el-col :span="8">
            <span style="margin:30px">联系地址：</span>
            <span>{{ selectItem.address }}</span>
          </el-col>
          <el-col :span="24">
            <div class="mores" style="margin-top:20px">
              <div class="more-title">填写信息</div>
            </div>
            <el-row>
              <span style="display: inline-block;width: 73px;text-align: right;">归档：</span>
              <el-select
                size="mini"
                style="width:90% !important"
                v-model="archivedData.fileStatus"
                placeholder="选择"
              >
                <el-option
                  v-for="(item, key, index) in dicts.FILE_STATUS"
                  :key="index"
                  :label="item"
                  :value="key"
                />
              </el-select>
            </el-row>
            <el-row style="margin-top:15px">
              <div style="display:flex;align-items: center;">
                <span style="display: inline-block;width: 73px;text-align: right;">备注：</span>
                <div style="display: inline-block;width: 90%;">
                  <el-input
                    size="mini"
                    v-model="archivedData.remark"
                    type="textarea"
                    placeholder="输入"
                  />
                </div>
              </div>
            </el-row>
          </el-col>
        </el-row>
      </div>

      <span slot="footer" class="dialog-footer">
        <el-button
          size="mini"
          type="primary"
          style="padding: 6px 19px;"
          @click="onSubmit('gdEdit')"
        >保存</el-button>
      </span>
    </el-dialog>

    <!-- 退款审核 -->
    <el-dialog :visible.sync="tkShow" width="80%" center custom-class="print-dialog">
      <span
        slot="title"
        class="dialog-title"
        style="font-size: 18px;font-weight: 400;color: #FFFFFF;"
      >结论修改</span>
      <el-table
        :data="tkList"
        style="width: 100%;padding:5px;"
        :header-cell-style="{
          background: '#333333',
          color: '#ffffff',
          textAlign: 'center'
        }"
      >
        <el-table-column align="center" type="index" width="35" />
        <el-table-column align="center" prop="momName" label="母亲姓名" />
        <el-table-column align="center" prop="babySex.data" label="婴儿性别" />
        <el-table-column align="center" prop="birthTime" label="出生日期" />
        <el-table-column align="center" prop="departId.data.label" label="所属部门" />
        <el-table-column align="center" prop="experimentValue" label="采样状态" />
        <el-table-column align="center" prop="refundAudit.data" label="退款审核">
          <template slot-scope="scope">
            <el-select size="mini" disabled v-model="scope.row.refundAudit.key" placeholder="全部">
              <el-option
                v-for="(item, key, index) in dicts.REFUND_AUDIT"
                :key="index"
                :label="item"
                :value="key"
              />
            </el-select>
          </template>
        </el-table-column>
        <el-table-column align="center" prop="refundReason.data" label="不通过原因">
          <template slot-scope="scope">
            <el-input
              v-model="scope.row.refundReason"
              size="mini"
              :disabled="scope.row.refundAudit.key == 'no' ? false : true"
            />
          </template>
        </el-table-column>
      </el-table>

      <span slot="footer" class="dialog-footer">
        <el-button
          size="mini"
          type="primary"
          style="padding: 6px 19px;"
          @click="onSubmit('tkEdit')"
        >保存</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { initDicts, downloadFile } from "@/utils/commons";
import orgApi from "@/api/Org.js";
import Project from "@/api/Project.js";
import SampleManageApi from "@/api/SampleManage.js";

export default {
  data() {
    return {
      // 出生日期输入格式
      birthTimeFormat: "MMdd",
      // 采血日期输入格式
      bloodTimeFormat: "MMdd",
      // 转菊花
      loading: false,
      // 是否展示更多信息
      morderShow: true,
      // 打印对话框
      dialogPrint: false,
      // 编辑对话框
      dialogEdit: false,
      // 是否显示打印按钮
      printStatus: true,
      // 归档弹窗显示
      gdShow: false,
      // 退款弹窗显示
      tkShow: false,
      // 弹窗标题
      loadingTitle: "修改/打印",
      // 表格数据
      tableData: [],
      // 选中数据
      selectTables: [],
      // 总数
      total: 0,
      // 基本数据
      basicData: {
        current: 1,
        map: {},
        model: {
          // 所属区县
          areaId: { key: "" },
          // 所属医院
          hospitalId: { key: "" },
          // 所属部门
          departId: { key: "" },
          // 母亲姓名
          momName: "",
          // 条形码号
          barCode: "",
          // 条形码号
          barCode: "",
          // 采样状态
          bloodStatus: { key: "" },
          // 归档状态
          fileStatus: { key: "" },
          // 出生日期
          birthTime: "",
          // 手机号码
          phone: "",
          // 支付方式
          payWay: { key: "" },
          // 费用类型
          costType: { key: "" },
          // 实验项目
          experimentProject: []
        },
        order: "descending",
        size: 10,
        sort: "id"
      },
      // 校验
      basicDataRules: {
        "areaId.key": [{ required: true, message: "必填", trigger: "change" }],
        "hospitalId.key": [
          { required: true, message: "必填", trigger: "change" }
        ],
        "departId.key": [
          { required: true, message: "必填", trigger: "change" }
        ],
        momName: [{ required: true, message: "必填", trigger: "change" }],
        phone: [
          { required: true, message: "必填", trigger: "change" },
          {
            required: true,
            pattern: /^1[3456789]\d{9}$/,
            message: "请输入正确格式的手机号",
            trigger: "blur"
          }
        ],
        weight: [
          { required: true, message: "必填", trigger: "change" },
          {
            pattern: /^[0-9]*$/,
            message: "请填写正确格式的数字",
            trigger: "change"
          },
          {
            required: true,
            validator: this.$weightNum,
            trigger: "blur",
            message: "请输入600—8000的数字"
          }
        ],
        weeks: [
          { required: true, message: "必填", trigger: "change" },
          {
            pattern: /^[0-9]*$/,
            message: "请填写正确格式的数字",
            trigger: "change"
          },
          {
            required: true,
            validator: this.$weeksNum,
            trigger: "blur",
            message: "请输入20—50的数字"
          }
        ],
        // days: [
        //   { required: true, message: "必填", trigger: "change" },
        //   {
        //     pattern: /^[0-9]*$/,
        //     message: "请填写正确格式的数字",
        //     trigger: "change"
        //   },
        //   {
        //     required: true,
        //     validator: this.$daysNum,
        //     trigger: "blur",
        //     message: "请输入0—6的数字"
        //   }
        // ],
        birthTime: [{ required: true, message: "  ", trigger: "change" }],
        bloodTime: [{ required: true, message: "  ", trigger: "change" }],
        babySex: [{ required: true, message: "  ", trigger: "change" }],
        barCode: [
          {
            required: true,
            message: "必填",
            trigger: "change"
          },
          {
            pattern: /^[0-9]*$/,
            message: "请填写正确格式的数字",
            trigger: "change"
          },
          {
            required: true,
            validator: this.$barCodeNum,
            trigger: "blur",
            message: "请输入14000000000—20999999999的数字"
          }
        ],
        costType: [{ required: true, message: "  ", trigger: "change" }],
        dadCard: [
          {
            pattern: /(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}$)/,
            message: "身份证号格式错误",
            trigger: "change"
          }
        ],
        momCard: [
          {
            pattern: /(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}$)/,
            message: "身份证号格式错误",
            trigger: "change"
          }
        ],
        freeNum: [
          {
            pattern: /^[0-9]*$/,
            message: "请填写正确格式的数字",
            trigger: "change"
          },
          {
            validator: this.$freeNum,
            message: "请输入200110001—200145000的数字",
            trigger: "change"
          }
        ]
      },
      // 字典
      dicts: {
        BLOOD_STATUS: {}, //采样状态
        PAY_WAY: {}, //交付方式
        FILE_STATUS: {}, //归档状态
        COST_TYPE: {}, //费用类型
        MOM_CENSUS: {}, //母亲户籍
        SAMPLE_QUALITY: {}, //样本质量
        EXPERIMENT_CODE: {}, //实验项目
        ACCOUNT_TYPE: {}, //户口类型
        REFUND_AUDIT: {}, //退款审核
        BABY_SEX: {} //性别
      },
      // 市县
      orgTree: [],
      // 医院
      orgTreeC: [],
      // 部门
      orgTreeCs: [],
      rowData: {
        // 户口类型【农村/城镇】
        accountType: {
          key: ""
        },
        // 住址
        address: "",
        // 所属区县
        areaId: {
          key: ""
        },
        // 婴儿性别【男/女/未知】
        babySex: {
          key: ""
        },
        // 条形码号
        barCode: "",
        // 出生日期
        birthTime: "",
        // 采血编号
        bloodNum: "",
        // 采血日期
        bloodTime: "",
        // 费用类型【自费/免费】
        costType: {
          key: ""
        },
        // 父亲身份证
        dadCard: "",
        // 孕天【0-6之间】
        days: "",
        // 所属部门
        departId: {
          key: ""
        },
        // 实验编号
        expNum: "",
        // 免费劵号
        freeNum: "",
        // 送检医生
        getexamineDoctor: "",
        // 医院id
        hospitalId: {
          key: ""
        },
        // 母亲身份证
        momCard: "",
        // 母亲户籍【本地/外地】
        momCensus: {
          key: ""
        },
        // 母亲姓名
        momName: "",
        // 手机号码
        phone: "",
        // 筛查备注
        remark: "",
        // 样本质量【默认合格，基础码表】
        sampleQuality: {
          key: ""
        },
        // 采血人
        samplingPeople: "",
        // 孕周【20-50之间】
        weeks: "",
        // 婴儿体重
        weight: "",
        // 实验项目
        experimentProject: []
      },
      selectItem: {
        // 户口类型【农村/城镇】
        accountType: {
          key: ""
        },
        // 住址
        address: "",
        // 所属区县
        areaId: {
          key: ""
        },
        // 婴儿性别【男/女/未知】
        babySex: {
          key: ""
        },
        // 条形码号
        barCode: "",
        // 出生日期
        birthTime: "",
        // 采血编号
        bloodNum: "",
        // 采血日期
        bloodTime: "",
        // 费用类型【自费/免费】
        costType: {
          key: ""
        },
        // 父亲身份证
        dadCard: "",
        // 孕天【0-6之间】
        days: "",
        // 所属部门
        departId: {
          key: ""
        },
        // 实验编号
        expNum: "",
        // 免费劵号
        freeNum: "",
        // 送检医生
        getexamineDoctor: "",
        // 医院id
        hospitalId: {
          key: ""
        },
        // 母亲身份证
        momCard: "",
        // 母亲户籍【本地/外地】
        momCensus: {
          key: ""
        },
        // 母亲姓名
        momName: "",
        // 手机号码
        phone: "",
        // 筛查备注
        remark: "",
        // 样本质量【默认合格，基础码表】
        sampleQuality: {
          key: ""
        },
        // 采血人
        samplingPeople: "",
        // 孕周【20-50之间】
        weeks: "",
        // 婴儿体重
        weight: "",
        // 实验项目
        experimentProject: []
      },
      // 归档数据
      archivedData: {
        archiveReason: {
          key: ""
        },
        fileStatus: {
          key: "archived"
        },
        remark: "",
        sampleId: 0
      },
      // 退款审核列表
      tkList: [],
      ids: []
    };
  },
  mounted() {
    initDicts(
      [
        "BLOOD_STATUS",
        "PAY_WAY",
        "FILE_STATUS",
        "COST_TYPE",
        "MOM_CENSUS",
        "SAMPLE_QUALITY",
        "EXPERIMENT_CODE",
        "ACCOUNT_TYPE",
        "REFUND_AUDIT",
        "BABY_SEX"
      ],
      this.dicts
    );
    // 获取基础查询
    this.initOrgTree();
    // 获取表格数据
    this.getList(this.basicData);
  },
  methods: {
    // 如果是打回来的就标红处理
    announStyle({ row }) {
      let rowStyle = {};
      if (row.bloodProperty.key == 'recheck') {
        rowStyle.background = "#d48e8e";
        rowStyle.color = "#fff";
        return rowStyle;
      }
    },
    // 出生日期输入
    changeBirthTime(v, type) {
      if (type == "b") {
        this.basicData.model.birthTime = v;
      }
      this.selectItem.birthTime = v;
      if (this.basicData.model.birthTime || this.selectItem.birthTime) {
        this.birthTimeFormat = "yyyy-MM-dd";
      } else {
        this.birthTimeFormat = "MMdd";
      }
    },
    // 采血日期输入
    changeBloodTime(v, type) {
      if (type == "b") {
        this.basicData.bloodTime = v;
      }
      this.selectItem.bloodTime = v;
      if (this.basicData.bloodTime || this.selectItem.bloodTime) {
        this.bloodTimeFormat = "yyyy-MM-dd";
      } else {
        this.bloodTimeFormat = "MMdd";
      }
    },
    // 修改项目选择
    clickCheckBox(v) {
      this.selectItem.experimentProject.list = v;
    },
    // 选中列表
    clickTable(v) {
      this.selectTables = v;
      this.ids = [];
      v.forEach(item => {
        this.ids.push(item.id);
      });
    },
    // 点击采样
    async clickButtom(v) {
      // this.selectItem = JSON.parse(JSON.stringify(v));
      // this.rowData = JSON.parse(JSON.stringify(this.selectItem));
      await SampleManageApi.sampleList({ id: v.id }).then(res => {
        this.selectItem = res.data.data;
        this.rowData = res.data.data;
      });
      this.selectItem.areaId = v.areaId;
      this.selectItem.hospitalId = v.hospitalId;
      this.selectItem.departId = v.departId;

      this.loadingTitle = "采样";
      this.orgTree.filter(res => {
        if (res.id == this.selectItem.areaId.key) {
          this.orgTreeC = res.children;
        }
      });
      this.orgTreeC.filter(res => {
        if (res.id == this.selectItem.hospitalId.key) {
          this.orgTreeCs = res.children;
        }
      });

      this.$router.push({
        path: "/samplingManage/sampleManage",
        query: this.selectItem
      });

      // this.dialogEdit = true;
    },
    // 修改/打印
    clickEdit() {
      if (this.selectTables.length > 1) {
        this.$message.error("只能选择一条数据哦");
        return;
      }
      this.loadingTitle = "修改/打印";
      // this.selectItem = JSON.parse(JSON.stringify(this.selectTables[0]));
      // this.rowData = JSON.parse(JSON.stringify(this.selectItem));
      SampleManageApi.sampleList({ id: this.selectTables[0].id }).then(res => {
        this.selectItem = res.data.data;
        this.rowData = res.data.data;
        this.dialogEdit = true;
      });

      this.selectTables.forEach((item, index) => {
        this.orgTree.filter(res => {
          if (res.id == item.areaId.key) {
            this.orgTreeC = res.children;
          }
        });
        this.orgTreeC.filter(res => {
          if (res.id == item.hospitalId.key) {
            this.orgTreeCs = res.children;
          }
        });
      });
    },
    // 删除
    clickDel() {
      this.$confirm("是否删除?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        let ids = [];
        this.selectTables.forEach(item => {
          ids.push(item.id);
        });
        SampleManageApi.notdelete({ ids: ids }).then(res => {
          if (res.status == "200") {
            this.getList(this.basicData);
            this.$message({
              type: "success",
              message: "删除成功!"
            });
          } else {
            this.$message.error(res.statusText);
          }
        });
      });
    },
    // 导出
    clickExport() {
      SampleManageApi.notexport(this.basicData).then(res => {
        downloadFile(res);
        if (res.status == "200") {
          this.$message({
            type: "success",
            message: "导出成功!"
          });
        } else {
          this.$message.error(res.statusText);
        }
      });
    },
    // 归档
    clickPgh() {
      if (this.selectTables.length > 1) {
        this.$message.error("只能选择一条数据");
      } else if (this.selectTables.length == 0) {
        this.$message.error("请选择数据");
      } else {
        this.selectItem = JSON.parse(JSON.stringify(this.selectTables[0]));
        SampleManageApi.notopenArchived({ id: this.selectItem.id }).then(
          res => {
            if (res.status == "200") {
              this.archivedData.sampleId = res.data.data.sampleId;
              this.archivedData.remark = res.data.data.remark;
              this.gdShow = true;
            } else {
              this.$message.error(res.statusText);
            }
          }
        );
      }
    },
    // 退款审核
    clickRefund() {
      let ids = this.ids.toString();
      SampleManageApi.openRefundAudit({ ids: ids }).then(res => {
        if (res.status == "200") {
          this.tkList = res.data.data;
          this.tkShow = true;
        } else {
          this.$message.error(res.statusText);
        }
      });

      // SampleManageApi.botrefundAudit(ids).then(res => {
      //   if (res.status == "200") {
      //     this.getList(this.basicData);
      //     this.$message({
      //       type: "success",
      //       message: "退款成功!"
      //     });
      //   } else {
      //     this.$message.error(res.statusText);
      //   }
      // });
    },
    // 获取table
    getList(data) {
      this.loading = true;
      SampleManageApi.notpage(data).then(res => {
        this.tableData = res.data.data.records;
        this.total = res.data.data.total;
        this.loading = false;
      });
    },
    // 根据选择市县获取医院
    clickOrgTree(v) {
      this.orgTreeC = [];
      this.orgTreeCs = [];
      this.basicData.model.hospitalId.key = "";
      this.basicData.model.departId.key = "";
      this.selectItem.hospitalId.key = "";
      this.selectItem.departId.key = "";
      this.orgTree.filter(res => {
        if (res.id == v) {
          this.orgTreeC = res.children;
        }
      });
    },
    // 根据选择市县获取医院
    clickOrgTreeC(v) {
      this.orgTreeCs = [];
      this.basicData.model.departId.key = "";
      this.selectItem.departId.key = "";
      this.orgTreeC.filter(res => {
        if (res.id == v) {
          this.orgTreeCs = res.children;
        }
      });
    },
    // 获取基础查询
    initOrgTree() {
      orgApi.allTree({}).then(response => {
        const res = response.data;
        this.orgTree = res.data[0].children;
      });
    },
    // 点击展示与收起
    onMoreStatus() {
      this.morderShow = !this.morderShow;
    },
    //点击全选
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    // 基础信息按钮点击事件
    onSubmit(type) {
      if (type == "query") {
        this.getList(this.basicData);
      } else if (type == "reset") {
        // 如果为true则清空表单
        this.$refs["basicForm"].resetFields();
      } else if (type == "seave") {
        // 设置选中值
        SampleManageApi.notupdate(this.selectItem).then(res => {
          if (res.status == "200") {
            this.getList(this.basicData);
            this.dialogEdit = false;
          } else {
            this.$message.error(res.statusText);
          }
        });
      } else if (type == "seaveAndPrint") {
      } else if (type == "gdEdit") {
        SampleManageApi.notarchived(this.archivedData).then(res => {
          if (res.status == "200") {
            this.getList(this.basicData);
            this.$message({
              type: "success",
              message: "归档成功!"
            });
            this.gdShow = false;
          } else {
            this.$message.error(res.statusText);
          }
        });
      } else if (type == "tkEdit") {
        SampleManageApi.refundAudit(this.tkList).then(res => {
          if (res.status == "200") {
            this.getList(this.basicData);
            this.$message({
              type: "success",
              message: "修改成功!"
            });
            this.tkShow = false;
          } else {
            this.$message.error(res.statusText);
          }
        });
      }
    },
    // 点击打印
    clickTruePrint() {
      this.handlePrintPrint();
    },
    // 打印事件
    handlePrintPrint() {
      if (this.upLoading) {
        this.$message({
          message: "数据加载中,请稍后...",
          type: "warning"
        });
      } else {
        this.CreateTablePage("print", "采血卡打印", "sampleManage");
      }
    },
    // 点击分页
    handleSizeChange: function(val) {
      this.basicData.size = val;
      this.getList(this.basicData);
    },
    // 选择页码
    handleCurrentChange: function(currentPage) {
      this.basicData.current = currentPage;
      this.getList(this.basicData);
    }
  },
  watch: {
    "basicData.model.birthTime": function(v) {
      this.changeBirthTime(v, "b");
    },
    "basicData.bloodTime": function(v) {
      this.changeBloodTime(v, "b");
    },
    "selectItem.birthTime": function(v) {
      this.changeBirthTime(v);
    },
    "selectItem.bloodTime": function(v) {
      this.changeBloodTime(v);
    }
  }
};
</script>

<style lang="less">
.flex {
  display: flex;
  align-items: center;
  justify-content: center;
}
#uncollectedManages {
  .el-form-item__content,
  .el-date-editor,
  .el-select,
  .el-textarea {
    width: 100% !important;
  }
  .pj {
    .el-form-item__label {
      width: 83px !important;
    }
  }
  // .el-form-item__content,
  // .el-date-editor {
  //   width: 60% !important;
  // }
  // .el-input {
  //   width: 80% !important;
  // }

  #guidang {
    .el-select {
      width: 100% !important;
    }
  }
  .el-select {
    width: 100% !important;
  }
  .mores {
    .flex;
    justify-content: flex-start;
    width: 100%;
    background: #188ff233;
    height: 30px;
    padding: 5px 8px;
    .more-title {
      font-family: SourceHanSansSC;
      font-style: normal;
      letter-spacing: 0px;
      line-height: 20px;
      text-decoration: none;
      margin-right: 1rem;
      font-size: 14px;
      font-weight: 500;
      color: #000;
    }
  }

  #shiyan {
    .projectIdList {
      width: 100%;
      .el-form-item__content {
        width: 80%;
      }
    }
  }
  .more-form {
    .more-row {
      .more-col {
        .remark {
          width: 100%;
          .el-form-item__content {
            width: 90%;
          }
        }
      }
    }
  }
  .buttom {
    width: 100%;
    .flex;
  }
  .el-dialog__header {
    border-bottom: 1px solid #e0e0e0;
  }
  .print-form {
    max-height: 500px;
    overflow: auto;
    display: flex;
    flex-direction: column;
    flex-flow: wrap;
    .print-item {
      width: 50%;
      .flex;
      justify-content: flex-start;
      color: #222222;
      font-size: 15px;
      margin-top: 10px;
      .title {
        font-weight: bold;
        flex: 0.4;
      }
      .value {
        flex: 0.6;
        font-weight: bold;
        overflow-wrap: anywhere;
      }
    }
  }
  .el-dialog__footer {
    .flex;
  }
  .el-dialog__header {
    background: #2669f3;
  }
}
</style>
